#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QKeyEvent>
#include <QPushButton>
#include <QProcess.h>
#include <QLabel>

namespace acl {
    class http_request;
}

class http_server;
class http_service;

struct timeval;

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class ChildWindows;

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    MainWindow(QWidget *parent, http_service& service);
    ~MainWindow();

    void setProgress(int n);

    const std::string* get_filepath(const char* path);

protected:
    void keyPressEvent(QKeyEvent *event);

    void onStartServer();
    void onHttpOptions();
    void onAddFile();

    void onClear();

    void onDialogAccepted(const QString &text);
    void closeEvent(QCloseEvent *event) override;

private:
    Ui::MainWindow *ui_;

    http_service   &service_;
    http_server    *server_ = nullptr;
    QProcess       *process_;
    struct timeval *stamp_;
    size_t idx_ = 0;
    std::map<std::string, std::string> files_;

    void showFiles();
};

#endif // MAINWINDOW_H
